package com.wantup.controller.v2;

import com.wantup.model.InMessage;
import com.wantup.model.OutMessage;
import com.wantup.service.WebSocketService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.handler.annotation.MessageMapping;
import org.springframework.messaging.handler.annotation.SendTo;
import org.springframework.stereotype.Controller;

@Controller
public class GameInfoControllerV2 {


    @Autowired
    private WebSocketService webSocketService;

    /**
     * 需要发布订阅
     * @param inMessage
     * @return
     */
    @MessageMapping("/v2/chat2")//路径的映射  只是 提供于 websocket 使用的
    public void getMessage(InMessage inMessage){
        System.out.println("连接建立"+inMessage);
        webSocketService.sendTopicMessage("/topic2/game_rank",inMessage);
    }


}
